package Demo1

import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by lenovo on 2017/9/26.
  */
object SparkSQLTest2 {

  def main(args: Array[String]) {
    System.setProperty("hadoop.home.dir","E://hadoop-liyadong//hadoop-2.7.1")

    val conf = new SparkConf().setMaster("local[2]").setAppName("SparkSQLTest2").set("spark.testing.memory","2147480000")
    val sc = new SparkContext(conf)
    val sparkSQL = new SQLContext(sc)

    val jsonpeople = sparkSQL.jsonFile("D://people.json")
    jsonpeople.registerTempTable("jsonTable")

    sparkSQL.sql("select * from jsonTable where age >= 25").collect().foreach(println)
  }
}
